import allure
import pytest
from web_test.page.login.login_page import LoginPage
from web_test.page.app import App

# # 附加cookies跳过登录
# @pytest.fixture(name='login_with_cookies', scope="session", autouse=True)
# def login_with_cookies():
#     with allure.step('login_with_cookies'):
#         login = LoginPage()
#         login.login_with_cookies()
#         print('\nfixture: login_with_cookies OK')

# 打开浏览器
@pytest.fixture(name="app", scope="session")
def start_app():
    with allure.step('app'):
        app = App()
        # app.start()
        print('\nfixture: app OK')
        yield app
        app.stop()


# def pytest_assertrepr_compare(config, op, left, right):
#     left_name, right_name = inspect.stack()[7].code_context[0].lstrip().lstrip('assert').rstrip('\n').split(op)
#     pytest_output = assertrepr_compare(config, op, left, right)
#     logging.debug("{0} is\n {1}".format(left_name, left))
#     logging.debug("{0} is\n {1}".format(right_name, right))
#     with allure.step("校验结果"):
#         allure.attach(str(left), left_name)
#         allure.attach(str(right), right_name)
#     return pytest_output